<?php
/**
* Django's templating engine (partial) PHP implementation.
* provides some template tags support
* @link http://djangoproject.com
* this file is from a webappkit package (kit)
* @link http://webappkit.net
* @package djtpl
* @author J.Ducastel <jeremie@ducastel.name>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

/**
* filter tag.
* applies filter to its content block.
*/
class djtplTagNode_filter extends djtplTagNode {

	/**
	* builds itself from tokens
	* @param djangoTplToken &$selfToken
	* @param array &$nextTokens djangoTplToken
	* @access public
	* @return bool
	*/
	function buildFromTokens(&$selfToken,&$nextTokens) {
		// parsing token
		$this->filters=explode('|',$selfToken->getTagDef());
		// getting child nodes
		$this->buildChildNodesFromTokens($nextTokens);
		return true;
	}/**/

	/**
	* is the node atomic (has no children)
	* @access public
	* @return bool
	*/
	function isAtomic() {
		return false;
	}/**/
	
	/**
	* renders as string
	* @param djangoTplContext &$context
	* @access public
	* @return string
	*/
	function render(&$context) {
		// rendering child nodes content
		$rendered=$this->renderChildNodes($context);
		// applying filters
		foreach ($this->filters as $filter)
			$rendered=djtplParser::applyFilter($rendered,$filter);
		return $rendered;
	}/**/
/*------------------------------------------------------------------------------
                                                                      properties
------------------------------------------------------------------------------*/
	/**
	* @var type desc
	*/
	var $tagname='filter';
}/* end of djtpltagnode_filter class */
?>
